package pl.matt.media.model.wrapper;

import java.util.ArrayList;
import java.util.Collection;

import pl.matt.model.Rectangle;
import pl.matt.opencv.model.Region;


public class OpenCVRegionsWrapper {

	@SuppressWarnings("unused")
	private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OpenCVRegionsWrapper.class);
	private Region[] regions;
	
	public OpenCVRegionsWrapper(Region[] regions) {
		this.regions = regions;	
	}
	
	public Collection<pl.matt.model.Rectangle> toRectangleCollection() {
		if (regions != null) {
			Collection<pl.matt.model.Rectangle> out = new ArrayList<pl.matt.model.Rectangle>(regions.length);
			for (Region region : regions) {
				//LOG.debug(region.getAngle() + " <-- region.getAngle()");
				Rectangle rectangle = new Rectangle(region);
				out.add(rectangle);
			}			
			return out;
		}
		return null;
	}
	
}
